/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Services;

import Entities.Artist;
import Entities.Movie;
import Entities.Song;
import Entities.Soundtrack;
import java.util.Date;
import javax.persistence.*;
import java.util.List;

/**
 *
 * @author Edwin
 */
public class SoundtrackService {

    protected EntityManager em;

    public SoundtrackService(EntityManager em) {
        this.em = em;
    }

    public Soundtrack createSoundtrack(Long id,String picture,
            List<Song> songEntitys,Movie movieEntity) {
        Soundtrack soundtrack = new Soundtrack(id);
        soundtrack.setPicture(picture);
        soundtrack.setSongEntitys(songEntitys);
//        soundtrack.setMovieEntity(movieEntity);
                
        em.persist(soundtrack);
        
        return soundtrack;
    }
    
    
    public void updateSoundtrack(Long id,String picture,
            List<Song> songEntitys,Movie movieEntity) {
        Soundtrack soundtrack = findSoundtrack(id);
        soundtrack.setPicture(picture);
        soundtrack.setSongEntitys(songEntitys);
//        soundtrack.setMovieEntity(movieEntity);
        
        em.persist(soundtrack);
    }  
        
    public void removeSoundtrack(Long ID) {
        Soundtrack soundtrack = findSoundtrack(ID);
        if (soundtrack != null) {
            em.remove(soundtrack);
        }
    }

    public Soundtrack findSoundtrack(Long ID) {
        return em.find(Soundtrack.class, ID);
    }

    
}
